import { avoidPwdLogin } from "../../utils/api";
Page({
  data: {},
  breakLoginPage() {
    wx.navigateTo({
      url: "../login/login"
    })
  },
  breakRegisteredPage() {
    wx.navigateTo({
      url: "../registered/registered"
    })
  },
  onShow() {
    this.getAvoidPwdLogin();
  },
  async getAvoidPwdLogin() {
    const data = await avoidPwdLogin();
    console.log(data);
    if (data) {
      wx.setStorage({ key: "userInfo", data });
      wx.switchTab({
        url: '../home/home'
      })
    } else {
      wx.removeStorage({
        key: 'token',
      });
      wx.removeStorage({
        key: "userInfo"
      })
      return;
    }
  }
})